{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Review\n",
    "\n",
    "1. Write a function that takes in a list of integers and returns the sum of all the even numbers in the list.\n",
    "\n",
    "```python\n",
    "def sum_even_numbers(numbers):\n",
    "    total = 0\n",
    "    for num in numbers:\n",
    "        if ???:\n",
    "            total += num\n",
    "    return total\n",
    "```\n",
    "\n",
    "2. Write a program that asks the user for their name and age, then prints out a message telling them how many years they have left until they turn 100 years old.\n",
    "\n",
    "```python\n",
    "name = input(\"What is your name?\")\n",
    "age = int(input(\"How old are you?\"))\n",
    "years_left = ???\n",
    "print(???)\n",
    "```\n",
    "\n",
    "3. Write a function that takes in a string and returns True if the string is a palindrome (reads the same forward and backward) and False otherwise.\n",
    "```python\n",
    "def is_palindrome(word):\n",
    "    ???\n",
    "    if ???:\n",
    "        return True\n",
    "    else:\n",
    "        return False\n",
    "```\n",
    "\n",
    "\n",
    "5. Write a function that takes in a list of strings and returns the longest string in the list.\n",
    "```python\n",
    "def find_longest_string(strings):\n",
    "    longest_string = \"\"\n",
    "    for string in strings:\n",
    "        if ???:\n",
    "            longest_string = string\n",
    "    return longest_string\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Typing Train\n",
    "\n",
    "https://www.typingtest.com/\n",
    "\n",
    "\n",
    "https://www.speedcoder.net/lessons/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "What is your name?RR\n",
      "How old are you?12\n"
     ]
    },
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for -: 'int' and 'str'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-2-5bc45f6e58c2>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0mname\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"What is your name?\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0mage\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"How old are you?\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0myears_left\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m100\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mage\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      4\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0myears_left\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'int' and 'str'"
     ]
    }
   ],
   "source": [
    "name = input(\"What is your name?\")\n",
    "age = input(\"How old are you?\")\n",
    "years_left = 100 - age\n",
    "print(years_left)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "088620748498986555555555555558394984658712345677900987654321\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "def is_palindrome(word):\n",
    "    reverse_word = word[::-1]\n",
    "    print(reverse_word)\n",
    "    if word == reverse_word:\n",
    "        print(True)\n",
    "    else:\n",
    "        print(False)\n",
    "\n",
    "is_palindrome(\"123321\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = \"123\"\n",
    "len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "3\n",
      "31234\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'00jjkgk2312314'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def find_longest_string(strings):\n",
    "    longest_string = \"\"\n",
    "    for string in strings:\n",
    "        print(longest_string)\n",
    "        if len (longest_string) < len (string):\n",
    "            longest_string = string\n",
    "    return longest_string\n",
    "\n",
    "find_longest_string([\"3\", \"31234\", '00jjkgk2312314'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Example file showing a circle moving on screen\n",
    "import pygame\n",
    "\n",
    "# pygame setup\n",
    "pygame.init()\n",
    "screen = pygame.display.set_mode((640, 320))\n",
    "clock = pygame.time.Clock()\n",
    "running = True\n",
    "dt = 0\n",
    "\n",
    "player_pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)\n",
    "\n",
    "while running:\n",
    "    # poll for events\n",
    "    # pygame.QUIT event means the user clicked X to close your window\n",
    "    for event in pygame.event.get():\n",
    "        if event.type == pygame.QUIT:\n",
    "            running = False\n",
    "\n",
    "    # fill the screen with a color to wipe away anything from last frame\n",
    "    screen.fill(\"purple\")\n",
    "\n",
    "    # write your code\n",
    "    pygame.draw.circle(screen, \"red\", player_pos, 40)\n",
    "\n",
    "    keys = pygame.key.get_pressed()\n",
    "    if keys[pygame.K_w]:\n",
    "        player_pos.y -= 300 * dt\n",
    "        player_pos.y = player_pos.y - 300 * dt\n",
    "    if keys[pygame.K_s]:\n",
    "        player_pos.y += 300 * dt\n",
    "    if keys[pygame.K_a]:\n",
    "        player_pos.x -= 300 * dt\n",
    "    if keys[pygame.K_d]:\n",
    "        player_pos.x += 300 * dt\n",
    "\n",
    "    # flip() the display to put your work on screen\n",
    "    pygame.display.flip()\n",
    "\n",
    "    # limits FPS to 60\n",
    "    # dt is delta time in seconds since last frame, used for framerate-\n",
    "    # independent physics.\n",
    "    dt = clock.tick(60) / 1000\n",
    "\n",
    "pygame.quit()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
